

#include "MfcDll.h"

//#ifdef _DEBUG
//#define new DEBUG_NEW
//#endif


BEGIN_MESSAGE_MAP(CMfcDllApp, CWinApp)
END_MESSAGE_MAP()


CMfcDllApp::CMfcDllApp()
{
}

CMfcDllApp theApp;
BOOL CMfcDllApp::InitInstance()
{
	CWinApp::InitInstance();
	
	return TRUE;
}

int CMfcDllApp::ExitInstance()
{
	// Without this, Dynamically unloading the MFC dll will crash
#ifdef _DEBUG   // entire file
	AfxEnableMemoryLeakDump(FALSE);
#endif
	return 0;
}

MFCDLL_API void MFC_LeakSimple()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	// Attempt to allocate and leak some form of memory
	CString* str_a = new CString(_T("I am a string in MFC"));
	CString* str_b = new CString(_T("Another string in MFC"));
	CString* str_c = DEBUG_NEW CString(_T("Another string in MFC"));
	CString* str_d = new (_NORMAL_BLOCK, __FILE__, __LINE__) CString(_T("4 parameter new for mfc"));
}

MFCDLL_API void MFC_LeakArray()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	
	// Attempt to allocate and leak an array of CStrings
	CString* mystr = new CString[3];

	CString* strArray = DEBUG_NEW CString[3];

	CString* another  = new (_NORMAL_BLOCK, __FILE__, __LINE__) CString[3];
}

